package model.kwalificatiebeheer;

import java.sql.Date;
import java.util.Observable;
import java.util.TreeSet;

public class KwalificatieDossier extends Observable{
	/**
	 * Variables
	 */
	private int id;
	private Long[] crebos;
	private Long cohort;
	private String sector;
	private String domain;
	private String branch;
	private TreeSet<Uitstroomrichting> uitstroomrichtingen = new TreeSet<Uitstroomrichting>();
	private TreeSet<Kerntaak> kerntaken = new TreeSet<Kerntaak>();
	
	/**
	 * Constructors
	 */
	public KwalificatieDossier(){
	}	
	public KwalificatieDossier(int id){
		this.id = id;
	}	
	public KwalificatieDossier(int id, Long[] crebos, Long startDate, String sector, String domain, String branch){
		this.id = id;
		this.crebos = crebos;
		this.cohort = startDate;
		this.sector = sector;
		this.domain = domain;
		this.branch = branch;
		KwalificatieDossiers.getInstance().addKwalificatieDossier(this);
		

		Uitstroomrichting ur1 = new Uitstroomrichting(1, this, "MD", "Media Development");
		Uitstroomrichting ur2 = new Uitstroomrichting(2, this, "AO", "Applicatie Ontwikkeling");
		addUitstroomrichting(ur1);
		addUitstroomrichting(ur2);
	}
	
	/**
	 * Getters and Setters
	 */
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public Long[] getCrebos() {
		return crebos;
	}

	public void setCrebos(Long[] crebos) {
		this.crebos = crebos;
	}

	public Long getCohort() {
		return cohort;
	}

	public void setCohort(Long startDate) {
		this.cohort = startDate;
	}

	public String getSector() {
		return sector;
	}

	public void setSector(String sector) {
		this.sector = sector;
	}

	public String getDomain() {
		return domain;
	}

	public void setDomain(String domain) {
		this.domain = domain;
	}

	public String getBranch() {
		return branch;
	}

	public void setBranch(String branch) {
		this.branch = branch;
	}

	public TreeSet<Uitstroomrichting> getUitstroomrichtingen() {
		return uitstroomrichtingen;
	}
	public TreeSet<Kerntaak> getKerntaken() {
		return kerntaken;
	}

	public void setKerntaken(TreeSet<Kerntaak> kerntaken) {
		this.kerntaken = kerntaken;
	}
	
	/**
	 * @name: 		addKerntaak
	 * @description:Adds a Kerntaak to the kerntaken list.
	 * @return:		void
	 */
	public void addKerntaak(Kerntaak kerntaak){
		kerntaken.add(kerntaak);
		setChanged();
		notifyObservers();
	}
	
	public Kerntaak getKerntaak(Kerntaak kerntaak){
		for(Kerntaak kt : kerntaken){
			if(kt.getId() == kerntaak.getId()){
				return kt;
			}
		}
		return kerntaak;
	}
	
	public void removeKerntaak(Kerntaak kerntaak){
		kerntaken.remove(kerntaak);
		setChanged();
		notifyObservers();
	}
	
	public void addToDossierList(){
		KwalificatieDossiers.getInstance().addKwalificatieDossier(this);
	}
	
	public void addUitstroomrichting(Uitstroomrichting ur){
		uitstroomrichtingen.add(ur);
	}
	
	/**
	 * @name: 		deleteKwalificatieDossier
	 * @description:deletes KwalificatieDossier
	 * @return:		void
	 */
	public void deleteKwalificatieDossier(){
		KwalificatieDossiers.getInstance().deleteKwalificatieDossier(this);
		setChanged();
		notifyObservers();
	}
	
	public void update(Long[] crebos, Long startDate, String sector, String domain, String branch){
		this.crebos = crebos;
		this.cohort = startDate;
		this.sector = sector;
		this.domain = domain;
		this.branch = branch;
		setChanged();
		notifyObservers();
	}

}
